import {createSelector} from 'reselect';
import {ReduxState} from 'types';

/**
 * dataStore数据
 */
export const selectDataState = (reduxState: ReduxState) => reduxState.dataState;

export const selectUser = createSelector(
  selectDataState,
  (dataState) => dataState.user,
);
// 获取token
export const selectToken = createSelector(
  selectDataState,
  (dataState) => dataState.token,
);

export const selectLocation = createSelector(
  selectDataState,
  (dataState) => dataState.location,
);

// 获取event详情数据
export const selectEventDetail = createSelector(
  selectDataState,
  (dataState) => dataState.eventDetail,
);

/**
 * settingStore数据
 */
export const selectSetting = (reduxState: ReduxState) =>
  reduxState.settingsState;
export const selectLangSetting = createSelector(
  selectSetting,
  (settingState) => settingState.locale,
);

/**
 * queryStore数据
 */
export const selectQueryState = (reduxState: ReduxState) =>
  reduxState.queryState;
// 获取channels数据
export const selectChannels = createSelector(
  selectQueryState,
  (queryState) => queryState.channels,
);
// 获取选中channel
export const selectChannel = createSelector(
  selectQueryState,
  (queryState) => queryState.selectdChannel,
);
// 获取选中DateId
export const selectQueryTimes = createSelector(
  selectQueryState,
  (queryState) => queryState.queryTimes,
);

/**
 * UIStore数据
 */
export const selectUIState = (reduxState: ReduxState) => reduxState.uiState;
// 获取选中Tab卡
export const selectActiveTab = createSelector(
  selectUIState,
  (uiState) => uiState.activeTab,
);
